﻿Imports System.Data.SqlClient
Imports PhDir.DAL
Imports PhDir.Model
Imports PhDir.Repository
Imports System.Collections.Generic

Namespace Repository.Phone

    Public Class UpdatePhoneNumber
        Implements IUpdate(Of Model.Phone)

        Public Function Update(oldPhone As Model.Phone, newPhone As Model.Phone) As Boolean _
            Implements IUpdate(Of Model.Phone).Update

            Dim isSuccess = False

            Using dbConnection = New DbConnection(DbContext.PhoneContext)
                dbConnection.AddParameter("@OldPhoneNumber", oldPhone.PhoneNumber)
                dbConnection.AddParameter("@NewPhoneNumber", newPhone.PhoneNumber)
                dbConnection.CommandText = StoredProceduresName.UpdatePhoneNumber
                dbConnection.CommandType = CommandType.StoredProcedure
                isSuccess = dbConnection.ExecuteNonQuery()
            End Using

            Return isSuccess

        End Function

    End Class
End Namespace
